/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package newsparser;

import java.io.Serializable;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;    
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author boyarskiy_km
 */
@ManagedBean
@SessionScoped
public class ConnectorDB implements Serializable{
    private final String url = "jdbc:postgresql://de-team.ru/news";
    private final String name = "news";
    private final String pass = "news1";
    public Connection conn = null;
    public Statement stmt = null;
    public ResultSet rs = null;
    public CallableStatement cstmt = null;
    private CallableStatement upperProc = null;
    
    
    public ConnectorDB() {
        try {
            Class.forName("org.postgresql.Driver");
            conn = DriverManager.getConnection(url,name, pass);
            stmt = conn.createStatement();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ConnectorDB.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(ConnectorDB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
    public void close(){
        try {
            this.rs.close();
            this.stmt.close();
            this.conn.close();      
        } catch (Exception ex) {
            Logger.getLogger(ConnectorDB.class.getName()).log(Level.SEVERE, null, ex);
        }    
    }
    


}
